<extend name="Extends/base"/>
<block name="title">提现申请</block>
<block name="css">
</block>
<block name="body_style">class="bgc-fff"</block>
<block name="body">
    <div class="c-main">
        <div class="plr15 apply-cont">
            <h2>提现至微信钱包</h2>
            <ul class="mb10 apply-list">
                <li>
                    <div class="apply-list-txt width-30">真实姓名</div>
                    <div class="apply-list-num c-position-r">
                        <input type="text" name="name" placeholder="请输入您的姓名" class="width-100 apply-input"/>
                        <div class="apply-clear"></div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="cost-cont pl15">
            <h4>请选择提现金额</h4>
            <ul class="cost-list clearfix">
                <li>
                    <a data-income="300" href="javascript:;">
                        <label>3元</label>
                    </a>
                </li>
                <li>
                    <a data-income="1000" href="javascript:;">
                        <label>10元</label>
                    </a>
                </li>
                <li>
                    <a data-income="2000" href="javascript:;">
                        <label>20元</label>
                    </a>
                </li>
                <li>
                    <a data-income="3000" href="javascript:;">
                        <label>30元</label>
                    </a>
                </li>
                <li>
                    <a data-income="5000" href="javascript:;">
                        <label>50元</label>
                    </a>
                </li>
                <li>
                    <a data-income="10000" href="javascript:;">
                        <label>100元</label>
                    </a>
                </li>
            </ul>
            <p>可提现金额 <span>{:changePrice($blance)}</span> 元，最低可提现 3 元</p>
        </div>
        <div class="plr15">
            <a href="javascript:;" class="apply-btn cost-btn">申请提现</a>
        </div>
        <div class="tx-explain">
            <h3>提现说明</h3>
            <div class="tx-explain-txt">
                <p>1.根据相关规定，微信必须完成实名认证才可提现；</p>
                <p>2.提现金额单笔最低 3 元，最高 100 元；</p>
                <p>3.如有其他问题，请立即联系官方客服。</p>
            </div>
        </div>
    </div>
</block>
<block name="js">
    <script type="text/javascript" src="__APPS__/js/api.js?v={:C('JS_CSS_VERSION')}"></script>
    <script type="text/javascript">
        var blance = parseInt("{$blance}");
        $('.c-main').on('click', '.cost-list a', function () {
            var income = $(this).attr('data-income');
            if (blance < parseInt(income)) {
                $.toast("余额不足");
                return false;
            }
            $(this).addClass('curr').parent().siblings().find('a').removeClass('curr');
        });

        $('.apply-btn').on('click', function () {
            var name = $.trim($('input[name=name]').val());
            if (!name) {
                $.toast("请输入真实姓名");
                return false;
            }
            var income = $('.cost-list .curr').attr('data-income');
            if (!income) {
                $.toast("请选择取现金额");
                return false;
            }

            doApplyWithdraw(name, income, function (res) {
                if (res.Code != 10000) {
                    $.toast(res.Message);
                    return false;
                }
                $.toast("申请成功，审核后发放", 2000, function () {
                    location.reload();
                })
            });
        });
    </script>
</block>